From: Florian Müllner Date: Wed, 16 Jun 2021 20:11:50 +0000 (+0200) Subject: screenshot: Restrict callers X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~574^2^2~27 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=dd2cd6286cd3175e1518038a173218671adc68ea;p=gnome-shell.git screenshot: Restrict callers The shell D-Bus API was always meant as a private API for core components, so enforce that by limiting caller to a list of allowed well-known names. Applications that want to request a screenshot can use the corresponding desktop portal. https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3943 Part-of: --- diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js index 81ab516b1..bf537b7d6 100644 --- a/js/ui/screenshot.js +++ b/js/ui/screenshot.js @@ -15,6 +15,7 @@ Gio._promisify(Shell.Screenshot.prototype, 'screenshot_area', 'screenshot_area_finish'); const { loadInterfaceXML } = imports.misc.fileUtils; +const { DBusSenderChecker } = imports.misc.util; const ScreenshotIface = loadInterfaceXML('org.gnome.Shell.Screenshot'); @@ -24,6 +25,12 @@ var ScreenshotService = class { this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell/Screenshot'); this._screenShooter = new Map(); + this._senderChecker = new DBusSenderChecker([ + 'org.gnome.SettingsDaemon.MediaKeys', + 'org.freedesktop.impl.portal.desktop.gtk', + 'org.freedesktop.impl.portal.desktop.gnome', + 'org.gnome.Screenshot', + ]); this._lockdownSettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.lockdown' }); @@ -46,6 +53,13 @@ var ScreenshotService = class { Gio.IOErrorEnum, Gio.IOErrorEnum.PERMISSION_DENIED, 'Saving to disk is disabled'); return null; + } else { + try { + this._senderChecker.checkInvocation(invocation); + } catch (e) { + invocation.return_gerror(e); + return null; + } } let shooter = new Shell.Screenshot(); @@ -254,6 +268,13 @@ var ScreenshotService = class { } async SelectAreaAsync(params, invocation) { + try { + this._senderChecker.checkInvocation(invocation); + } catch (e) { + invocation.return_gerror(e); + return; + } + let selectArea = new SelectArea(); try { let areaRectangle = await selectArea.selectAsync(); @@ -269,6 +290,13 @@ var ScreenshotService = class { } FlashAreaAsync(params, invocation) { + try { + this._senderChecker.checkInvocation(invocation); + } catch (e) { + invocation.return_gerror(e); + return; + } + let [x, y, width, height] = params; [x, y, width, height] = this._scaleArea(x, y, width, height); if (!this._checkArea(x, y, width, height)) {